﻿CREATE PROCEDURE [ProductFeedback].[GetProductFeedbackBadgeCategoryRelations]
	@TenantId uniqueidentifier,
	@CatalogId [ProductFeedback].[TCatalogId],
	@CategoryId [ProductFeedback].[TCategoryId]
AS

-- 1st
SELECT
	PFBCA.BadgeId,
	PFBCA.StartDate,
	PFBCA.FinishDate,
	PFBCA.DisplayOrder
FROM
	ProductFeedbackBadgeCategoryAssociation PFBCA
	INNER JOIN ProductFeedbackBadge PFB ON PFBCA.TenantId = PFB.TenantId AND PFBCA.BadgeId = PFB.BadgeId
WHERE
	PFBCA.CatalogId = @CatalogId
	AND PFBCA.CategoryId = @CategoryId
	AND PFB.TenantId = @TenantId

-- 2nd
SELECT
	PFBCD.BadgeId,
	PFBCD.StartDate,
	PFBCD.FinishDate
FROM
	ProductFeedbackBadgeCategoryDisassociation PFBCD
	INNER JOIN ProductFeedbackBadge PFB ON PFBCD.TenantId = PFB.TenantId AND PFBCD.BadgeId = PFB.BadgeId
WHERE
	PFBCD.CatalogId = @CatalogId
	AND PFBCD.CategoryId = @CategoryId
	AND PFB.TenantId = @TenantId
